<template>
  <div :style="{ height: height, width: width }" />
</template>

<script>
import echarts from "echarts";
import { getBusinessOpportunitiesStage30 } from "@/api/province_jsc";
require("echarts/theme/macarons"); // echarts theme
import resize from "./mixins/resize";
const animationDuration = 3000;
const emphasisStyle = {
  itemStyle: {
    barBorderWidth: 1,
    shadowBlur: 10,
    shadowOffsetX: 0,
    shadowOffsetY: 0,
    shadowColor: "rgba(0,0,0,0.5)",
  },
};
export default {
  mixins: [resize],
  props: {
    listQuery: {
      type: Object,
    },
    width: {
      type: String,
      default: "1200px",
    },
    height: {
      type: String,
      default: "350px",
    },
    autoResize: {
      type: Boolean,
      default: true,
    },
  },
  data() {
    return {
      showbtns: false,
      chart: null,
      xData: [],
      yData: [],
    };
  },

  mounted() {
    this.getList();
  },
  beforeDestroy() {
    if (!this.chart) {
      return;
    }
    this.chart.dispose();
    this.chart = null;
  },
  methods: {
    handleClose() {
      this.editDisabled = false;
    },
    handleShowSearch() {
      this.showbtns = !this.showbtns;
    },
    getList() {
      getBusinessOpportunitiesStage30(this.listQuery).then((res) => {
        this.xData = res.data.data.map(function (obj, index, array) {
          var rObj = [];
          rObj = obj.stage;
          return rObj;
        });
        this.yData = res.data.data.map(function (obj, index, array) {
          var rObj2 = [];

          rObj2 = obj.contractAmount;
          return rObj2;
        });
        this.$nextTick(() => {
          this.initChart();
        });
      });
    },
    initChart() {
      let _self = this;
      this.chart = echarts.init(this.$el, "macarons");
      this.chart.setOption({
        // color: ["#ff89b0ff", "#ffcf5aff", "#6ef3edff",'#ab84fff','#52a8feff'],

        color: ["#3398DB"],
        tooltip: {
          trigger: "axis",
          axisPointer: {
            // 坐标轴指示器，坐标轴触发有效
            type: "shadow", // 默认为直线，可选为：'line' | 'shadow'
          },
        },
        grid: {
          left: "3%",
          right: "4%",
          bottom: "3%",
          containLabel: true,
        },
        xAxis: [
          {
             type: "category",
             axisTick:{
              show:false
            },
            data: this.xData,
            axisTick: {
              alignWithLabel: true,
            },
            
            axisLine: {
              
              lineStyle: {
                color: "#616266",
              },
            },
          },
        ],
          yAxis: [
          {
            type: "value",
             axisLine: {
                show:false,
              lineStyle: {
                color: "#616266",
              },
            },
            axisTick: {
              show: false,
            },
              axisLine: {
                show:false,
              lineStyle: {
                color: "#616266",
              },
            },
              axisTick:{
              show:false
            },
            axisLabel: {
              formatter: "{value} 元",
              textStyle: {
                color: "#616266",
              },
            },
          },
        ],
        series: [
          {
            name: "商机",
            type: "bar",
            barWidth: "60px",
            data: this.yData,
          },
        ],
      });
    },
  },
};
</script>
